package cn.xiangxu.telecom.cost.controller;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.xiangxu.telecom.cost.entity.CostInfo;
import cn.xiangxu.telecom.cost.service.CostService;
import cn.xiangxu.telecom.login.service.ApplicationException;

@Controller
public class CostController implements Serializable {
	@Resource(name="costService")
	private CostService cs;
	
	@RequestMapping("/toCost.do")
	public String toCost(HttpServletRequest request) {
		List<CostInfo> list = new ArrayList<CostInfo>();
		try {
			list = cs.checkNull();
		} catch(Exception e) {
			e.printStackTrace();
			if(e instanceof ApplicationException) {
				return "exception/noData";  //应该返回一个没有查询到数据的页面（此处简化了）
			}
			return "exception/error";
		}
		request.setAttribute("costInfo", list);
		
		return "cost/find";
	}
	
	@RequestMapping("/toAddCost.do")
	public String toAddCost() {
		System.out.println("增加资费逻辑处理...");
		return "cost/add";
	}
	
	
}








